package com.bluesky.objectworld.io;

import com.bluesky.objectworld.ObjectImpl;
import com.bluesky.objectworld._Object;
import com.bluesky.objectworld.method.NativeMethod;
import com.bluesky.objectworld.primitive._Boolean;
import com.bluesky.objectworld.primitive._Integer;
import com.bluesky.objectworld.primitive._String;

public class Console extends ObjectImpl {

	public Console() {

		// add println method
		NativeMethod newLine = new NativeMethod(this, "newLine");
		addMethod("newLine", newLine);

		NativeMethod print = new NativeMethod(this,"print");
		addMethod("print", print);

	}

	public _Object print(_Object obj) {		 

		Object value = null;
		if (obj instanceof _Integer)
			value = ((_Integer) obj).value;
		else if (obj instanceof _String)
			value = ((_String) obj).value;
		else if (obj instanceof _Boolean)
			value = ((_Boolean) obj).value;
		else
			throw new RuntimeException("unknow parameter of message: print");

		System.out.print(value);

		return null;

	}

	public _Object newLine() {
		System.out.println("<CR>");
		return null;
	}

}
